package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-07-11
 * Time: 13:53
 */
public class Test{

    public void indexAdd(int index,int data){
        //找到该节点
        ListNode cur = head;
        ListNode newNode = new ListNode(data);
        while(index != 0){
            cur = cur.next;
            index--;
        }
        newNode.prev = cur.prev;
        newNode.next = cur;
        cur.prev.next = newNode;
        cur.prev = newNode;
    }

    public int size(){
        int ret = 0;
        ListNode cur = head;
        while(cur != null){
            ret++;
            cur = cur.next;
        }
        return ret;
    }
    public void display(){
        ListNode cur = head;
        while(cur != null){
            System.out.print(cur.value + " ");
            cur = cur.next;
        }
        System.out.println();
    }

    public boolean contains(int key){
        ListNode cur = head;
        while(cur != null){
            if(cur.value == key){
                return true;
            }
            cur = cur.next;
        }
        return false;
    }

    public static void main(String[] args) {

    }
}
